package cn.iocoder.yudao.framework.business.order.dao;

import cn.iocoder.yudao.framework.business.basic.dao.mapper.CoreMapper;
import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.order.pojo.po.OrderEntity;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 订单 Mapper，由子类继承，子类标注 @{@link org.apache.ibatis.annotations.Mapper}
 *
 * @author 山野羡民
 */
//@org.apache.ibatis.annotations.Mapper
public interface OrderMapper<DO extends OrderEntity> extends CoreMapper<DO> {

    default DO selectByTradeNo(String tradeNo) {
        return selectOne("trade_no", tradeNo);
    }

    default List<DO> selectListByPayedAndLessThanCreateTime(boolean payed, LocalDateTime createTime) {
        CoreQueryWrapper<DO> wrapper = new CoreQueryWrapper<>();
        wrapper.eqIfPresent("payed", payed);
        wrapper.lt("create_time", createTime);
        return selectList(wrapper);
    }

}
